package com.dstz.bpm.engine.model;

import com.dstz.base.core.util.StringUtil;
import com.dstz.org.api.model.IUser;
import com.dstz.sys.api.model.SysIdentity;

/** @deprecated */
@Deprecated
public class BpmIdentity implements SysIdentity {
   private static final long serialVersionUID = 4416404339210896051L;
   private String id;
   private String name;
   private String type;

   public BpmIdentity() {
   }

   public BpmIdentity(String id, String name, String type) {
      this.id = id;
      this.name = name;
      this.type = type;
   }

   public BpmIdentity(IUser user) {
      this.id = user.getUserId();
      this.name = user.getFullname();
      this.type = "user";
   }

   public void setId(String id) {
      this.id = id;
   }

   public String getId() {
      return this.id;
   }

   public void setName(String name) {
      this.name = name;
   }

   public String getName() {
      return this.name;
   }

   public void setType(String type) {
      this.type = type;
   }

   public String getType() {
      return this.type;
   }

   public int hashCode() {
      return this.id.hashCode() + this.type.hashCode();
   }

   public boolean equals(Object obj) {
      if (!(obj instanceof SysIdentity)) {
         return false;
      } else if (!StringUtil.isEmpty(this.id) && !StringUtil.isEmpty(this.name)) {
         SysIdentity identity = (SysIdentity)obj;
         return this.type.equals(identity.getType()) && identity.getId().equals(this.id);
      } else {
         return false;
      }
   }
}
